package com.ui.exg4pcd;

import com.ui.exg4pcd.R;

import android.os.Bundle;
import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;

public class TablActivity extends TabActivity {

	public static final String TAB_HOME = "tabHome";
	public static final String TAB_HISTORY = "tabHistory";
	public static final String TAB_SPORTZONE = "tabSportzone";
	public static final String TAB_MORE = "tabMore";

	private TabHost tabHost;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_tabl);
		this.tabHost=getTabHost();
		this.tabHost.addTab(this.tabHost.newTabSpec(TAB_HOME)//添加一个标识为TAB_HOME的Tab分页	
				.setIndicator(TAB_HOME)//设定分页显示的标题
				.setContent(new Intent(this, com.activity.exg4pcd.MainActivity.class)));
		this.tabHost.addTab(this.tabHost.newTabSpec(TAB_HISTORY)//添加一个标识为TAB_HOME的Tab分页	
				.setIndicator(TAB_HISTORY)//设定分页显示的标题
				.setContent(new Intent(this, com.activity.exg4pcd.ExchangeActivity.class)));
		//设定分页所关联的界面
		
		this.setDefaultTab(0);
		this.tabHost.setOnTabChangedListener(new OnTabChangeListener() {

			@Override
			public void onTabChanged(String tabId) {
				// TODO Auto-generated method stub

			}
		});

		View tab1 = findViewById(R.id.tab1);
		tab1.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {

				tabHost.setCurrentTabByTag(TAB_HOME);
			}
		});

		View tab2 = findViewById(R.id.tab2);
		tab2.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				tabHost.setCurrentTabByTag(TAB_HISTORY);

			}
		});
		View tab3 = findViewById(R.id.tab3);
		tab3.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {

				tabHost.setCurrentTabByTag(TAB_SPORTZONE);
			}
		});
		View tab4 = findViewById(R.id.tab4);
		tab4.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {

				tabHost.setCurrentTabByTag(TAB_MORE);
			}
		});
		
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_tabl, menu);
		return true;
	}

}
